﻿@page "/CKPage"
@inject RkServer rkServer
@inject FinshGetServer finshGetServer
@using System.ComponentModel
@using AntDesign.TableModels
@inject ModalService _modalService
@inject MessageService _message
<h3>成品出库</h3>
<div>
    <Row>
        <Col Span="24">扫码输入框</Col>
    </Row>
    <Row>
        <Col Span="24">
        <Input style="width:100%" Placeholder="Basic usage" @bind-Value="@ss" @onkeydown="Change" />
        </Col>
    </Row>
    <Row>
        <Col Span="24">批号</Col>
    </Row>
    <Row>
        <Col Span="24">
        <Input style="width:100%" Placeholder="Beath" @bind-Value="@Batch" />
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <Button style="width:100%" Type="@ButtonType.Primary">解析二维码</Button>
        <br>
        <br>
        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@Creat">提交出库任务</Button>
        <br>
        </Col>
    </Row>
</div>

@code {
    string Batch { get; set; }
    string ss { get; set; }
    protected override async Task OnInitializedAsync()
    {
        base.OnInitialized();
    }

    private async void Change(KeyboardEventArgs e)
    {
       
        if (e.Key != "Enter") return;
        if (!string.IsNullOrEmpty(ss))
        {

            var a = ss.Split(',');
            Batch = a[0];
            //for (int i = 0; i < a.Length; i++)
            //{
            //    if (a[i].Contains("Flot"))
            //    {
            //        Batch = a[i].Remove(0, 4);
            //    }
            //}
        }


    }
    private async Task Creat()
    {
      await  _modalService.ConfirmAsync(new ConfirmOptions()
            {
                Title = "提示",
                Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
            OkText = "确认",
            OnOk = async (e) =>
            {
                var aa = await rkServer.TaskCreatCK(Batch);
                _message.Info(aa);
            },
            CancelText = "取消",
            Content = "是否提交？",
        });
        ss="";
        Batch = "";



    }
}
